#include <iostream>
#include <string>

int n;

bool check(std::string s)
{
	for (int i = 0; i < (int)s.size(); i++)
		if (s[i] == '0') return false;
	for (int i = 0; i < (int)s.size(); i++)
		for (int j = i+1; j < (int)s.size(); j++)
			if ((s[i]-'0') % (s[j]-'0') != 0) return false;
	return true;
}

int main()
{
	std::cin >> n;
	std::cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++)
		if (check(std::to_string(i))) ans++;
	std::cout << ans << '\n';
}

